package com.winglish.as3.exam.toeicspeaking 
{
	import com.winglish.as3.exam.toeicspeaking.impl.TSPart;
	import com.winglish.as3.utils.StringUtil;
	import com.winglish.as3.utils.NumberUtil;
	
	import flash.display.MovieClip;
	import flash.text.TextFieldAutoSize;
	import flash.events.MouseEvent;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author charmjin
	 */
	public class TSPart2 extends TSAnswer implements TSPart
	{
		private var img:Object;
		
		public function TSPart2(mc:MovieClip, data:Object, imgObj:Object) 
		{
			super(mc, data, 2);
			img = imgObj;
		}
		
		/**
		 * 사운드재생, 녹음, 공백시간 등이 끝나고 나서 실행하는 함수.
		 * @param	no
		 */
		public function action(no:int):void {
			var mcRoot:MovieClip = _root.mcRoot;
			switch(no) {
				case 1 :	//preparing
					_root.gotoAndStop("part" + partNo + "_Q");
					mcRoot = _root.mcRoot;	//nextFrame 이동으로 mcRoot 내용이 달라지기 때문에 다시 넣기.
					mcRoot.secTxt.text = NumberUtil.itostr(TSData["PART" + partNo][2]);
					mcRoot.imgLoadMc.x = -img.width / 2;
					mcRoot.imgLoadMc.addChild(img);
					break;
				case 3 :	//reading
					mcRoot.nextFrame();
					mcRoot.secTxt.text = NumberUtil.itostr(TSData["PART" + partNo][4].split("r")[0]);
					break;
				case 5 :	//end
					_root.gotoAndStop("part" + partNo + "_A");
					answerSet();
					break;
			}
			
		}
		
		/**
		 * 피드백 텍스트 셋팅.
		 */
		override protected function answerSet():void {
			super.answerSet();
			_root.mcRoot.imgLoadMc.x = (TSData.PART2_IMG_AREA / 2) - img.width / 2;
			_root.mcRoot.imgLoadMc.addChild(img);
		}
		
		/**
		 * 나의 답변, 모범 답변 사운드 셋팅.
		 * @param	ansArr
		 * @param	recArr
		 */
		override public function soundRecordSet(ansArr:Array, recArr:Array):void {
			super.soundRecordSet(ansArr, recArr);
		}

		/**
		 * 다시풀기 버튼 클릭
		 * @param	e
		 */
		override public function reStartBtnClick(e:MouseEvent):void {
			reStartBtnClick(e);
			dispatchEvent(new Event("reStart", true));
			_root.gotoAndPlay("part" + partNo);
		}
	}

}